package com.tancire.net.service.impl;

import java.util.List;
import javax.annotation.Resource;

import com.tancire.common.utils.DateUtils;
import org.springframework.stereotype.Service;
import com.tancire.net.mapper.CrmCompanyIncomeDetailMapper;
import com.tancire.net.domain.CrmCompanyIncomeDetail;
import com.tancire.net.service.ICrmCompanyIncomeDetailService;

/**
 * 收益明细Service业务层处理
 *
 * @author chenchao
 * @date 2023-12-25
 */
@Service
public class CrmCompanyIncomeDetailServiceImpl implements ICrmCompanyIncomeDetailService {
    @Resource
    private CrmCompanyIncomeDetailMapper crmCompanyIncomeDetailMapper;

    /**
     * 查询收益明细
     *
     * @param id 收益明细主键
     * @return 收益明细
     */
    @Override
    public CrmCompanyIncomeDetail selectCrmCompanyIncomeDetailById(Long id) {
        return crmCompanyIncomeDetailMapper.selectCrmCompanyIncomeDetailById(id);
    }

    /**
     * 查询收益明细列表
     *
     * @param crmCompanyIncomeDetail 收益明细
     * @return 收益明细
     */
    @Override
    public List<CrmCompanyIncomeDetail> selectCrmCompanyIncomeDetailList(CrmCompanyIncomeDetail crmCompanyIncomeDetail) {
        return crmCompanyIncomeDetailMapper.selectCrmCompanyIncomeDetailList(crmCompanyIncomeDetail);
    }

    /**
     * 新增收益明细
     *
     * @param crmCompanyIncomeDetail 收益明细
     * @return 结果
     */
    @Override
    public int insertCrmCompanyIncomeDetail(CrmCompanyIncomeDetail crmCompanyIncomeDetail) {
        crmCompanyIncomeDetail.setCreateTime(DateUtils.getNowDate());
        return crmCompanyIncomeDetailMapper.insertCrmCompanyIncomeDetail(crmCompanyIncomeDetail);
    }

    /**
     * 修改收益明细
     *
     * @param crmCompanyIncomeDetail 收益明细
     * @return 结果
     */
    @Override
    public int updateCrmCompanyIncomeDetail(CrmCompanyIncomeDetail crmCompanyIncomeDetail) {
        crmCompanyIncomeDetail.setUpdateTime(DateUtils.getNowDate());
        return crmCompanyIncomeDetailMapper.updateCrmCompanyIncomeDetail(crmCompanyIncomeDetail);
    }

    /**
     * 批量删除收益明细
     *
     * @param ids 需要删除的收益明细主键
     * @return 结果
     */
    @Override
    public int deleteCrmCompanyIncomeDetailByIds(Long[] ids) {
        return crmCompanyIncomeDetailMapper.deleteCrmCompanyIncomeDetailByIds(ids);
    }

    /**
     * 删除收益明细信息
     *
     * @param id 收益明细主键
     * @return 结果
     */
    @Override
    public int deleteCrmCompanyIncomeDetailById(Long id) {
        return crmCompanyIncomeDetailMapper.deleteCrmCompanyIncomeDetailById(id);
    }

    /**
     * 删除明细表数据
     *
     * @param id
     */
    @Override
    public void deleteByTaskId(Long id) {
        this.crmCompanyIncomeDetailMapper.deleteByTaskId(id);
    }

    /**
     * 查询饼图数据
     *
     * @param crmCompanyIncomeDetail
     * @return
     */
    @Override
    public List<CrmCompanyIncomeDetail> selectCompanyIncomeDetailList(CrmCompanyIncomeDetail crmCompanyIncomeDetail) {
        return this.crmCompanyIncomeDetailMapper.selectCompanyIncomeDetailList(crmCompanyIncomeDetail);
    }

    /**
     * 更新预估收益
     *
     * @param detail
     */
    @Override
    public void updateIncomeAmount(CrmCompanyIncomeDetail detail) {
        this.crmCompanyIncomeDetailMapper.updateIncomeAmount(detail);
    }
}
